import React from 'react'
import { Router, Route, IndexRoute } from 'react-router'
import Frame from 'app/shared/layouts/frame'
import Intl from 'i18n/intl'

const ArticleList = (location, callback) => {
  require.ensure([], require => {
    callback(null, require('app/article/list'))
  }, 'ArticleList')
}
const ArticleDetail = (location, callback) => {
  require.ensure([], require => {
    callback(null, require('app/article/detail'))
  }, 'ExampleDetail')
}
const ArticleAdd = (location, callback) => {
  require.ensure([], require => {
    callback(null, require('app/article/add'))
  }, 'ArticleAdd')
}
const MyArticle = (location, callback) => {
  require.ensure([], require => {
    callback(null, require('app/article/mine'))
  }, 'MyArticle')
}

const routes = history => (
  <Router history={history}>
    <Route component={Intl}>
      <Route path='/' component={Frame}>
        <IndexRoute getComponent={ArticleList} />
        <Route path='/detail/:id' getComponent={ArticleDetail} />
        <Route path='/add' getComponent={ArticleAdd} />
        <Route path='/mine' getComponent={MyArticle} />
      </Route>
    </Route>
  </Router>
)

export default routes
